package servlets;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dataTypes.*;


@SuppressWarnings("serial")
public class setUserPrefs extends HttpServlet {

	public setUserPrefs() {
		super();
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		try {
			response.setContentType("text/html");

			String location = request.getParameter("location");
			int type = Integer.parseInt(request.getParameter("type"));
			int maxNumOfNotifications = Integer.parseInt(request.getParameter("maxNumOfNotificatins"));

			String googleName;			
			if ((googleName=appManager.getInstance().getGoogleName(request))==null)
				appManager.getInstance().signIn(request, response);
			else {	
				appManager.getInstance().setPrefs(location, type, maxNumOfNotifications, googleName);
			}
			
		} catch (Exception e) { 
			e.printStackTrace();
		}		

	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
